{template 'common/header'}

{template 'common'}

<div class="main">

	<ul class="nav nav-tabs">

		<li{if $_GPC['do'] == 'manage'} class="active"{/if}><a href="{php echo $this->createWebUrl('manage');}">兑奖管理</a></li>

		<li{if $_GPC['do'] == 'post'} class="active"{/if}><a href="{php echo url('platform/reply/post',array('m'=>'laoyou_csyx'));}">添加规则</a></li>

		<li{if $_GPC['do'] == 'awardlist'} class="active"{/if}><a href="{php echo $this->createWebUrl('awardlist',array('name'=>'laoyou_csyx', 'rid' => $rid));}">中奖名单</a></li>

	</ul>

    <div class="panel panel-info">

	<!-- <div class="panel-heading">筛选</div>

	<div class="panel-body">

		<form action="{php echo create_url('site', array('do' => 'awardlist', 'name' => 'laoyou_csyx','rid'=>$rid))}" method="get" class="form-horizontal" role="form">

			<input type="hidden" name="c" value="site" />

			<input type="hidden" name="a" value="entry" />

        	<input type="hidden" name="m" value="ewei_scratch" />

        	<input type="hidden" name="do" value="awardlist" />

        	<input type="hidden" name="rid" value="{$_GPC['rid']}" />

			<div class="form-group">

				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>

				<div class="col-xs-12 col-sm-8 col-lg-9">

					<input class="form-control" name="keywords" id="" type="text" value="{$_GPC['keywords']}" placeholder="可查询SN码">

				</div>

			</div>

			<div class="form-group">

				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>

				<div class="col-xs-12 col-sm-8 col-lg-9">

					<select name="status" class="form-control" style="float:left">

                    	<option value="" {if $_GPC['status']==''}selected{/if}>全部</option>

                        <option value="1" {if $_GPC['status']=='1'}selected{/if}>未兑换</option>

                        <option value="2" {if $_GPC['status']=='2'}selected{/if}>已兑换</option>

                	</select>

				</div>

                <div class=" col-xs-12 col-sm-2 col-lg-2">

					<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>

				</div>

			</div>

		</form>

	</div> -->

</div>

<div class="panel panel-default">

<div class="panel-heading">

	<div class="row-fluid">

    	<div class="span8 control-group">

			<a class="btn btn-default" href="{php echo $this->createWebUrl('download',array('rid'=>$rid))}"><i class="icon-download-alt"></i>导出SN码和兑奖信息</a>

			<a class="btn btn-default" href="{php echo $this->createWebUrl('awardlist',array('rid'=>$rid))}">全部</a>

<!--			<a class="btn btn-default" href="{php echo $this->createWebUrl('awardlist',array('rid'=>$rid,'status'=>1))}">未兑换</a>

			<a class="btn btn-default" href="{php echo $this->createWebUrl('awardlist',array('rid'=>$rid,'status'=>2))}">已兑换</a>-->

        </div>

    </div>

	<div class="alert" style="margin-bottom:0;">

		<!-- 本次活动奖品总数：{$num1}个　-->抽中未兑换：{$num2}个　　抽中已兑换：{$num3}个　　 领取规则 : 先到先得！

	</div>

</div>

	<div style="position:relative">

		<div class="panel-body table-responsive">

			<table class="table table-hover" style="position:relative">

			<thead class="navbar-inner">

				<tr>
					<th class='with-checkbox' style="width:50px;">
						<input type="checkbox" class="check_all" />
					</th>

					<th style="width:50px;">序号</th>

					<th style="width:150px;">SN码</th>

					<th style="width:80px;">奖品类别</th>

					<th style="width:80px;">状态</th>

					<th width="200px">领取者微信号</th>

					<th style="width:80px;">姓名</th>

					<th style="width:200px;">电话</th>

					<!-- <th width="300px">收货地址</th> -->
					<th width="300px">微信ID</th>

					<!-- <th style="width:120px;">领取者微信码</th> -->

					<th style="width:120px;">中奖时间</th>

					<th style="width:120px;">使用时间</th>

					<th style="width:300px;">操作</th>

				</tr>

			</thead>

			<tbody>

				{loop $list $row}

				<tr>
					<td class="with-checkbox">
						<input type="checkbox" name="check" value="{$row['id']}">
					</td>

					<td>{$row['id']}</td>

                	<td>{$row['award_sn']}</td>

					<td>{$row['name']}</td>

					<td>{if $row['status']==0}<span class="label label-default">未领取</span>

						{elseif $row['status']==1}<span class="label label-success">未兑换</span>

						{else}<span class="label label-warning">已兑换</span>{/if}</td>

					<!-- <td><span class="label label-info phone" data-fans="{$row['from_user']}"}>显示手机号</span></td> -->

					<td>{$row['from_user']}</td>

					<td>{$row['username']}</td>

					<td>{$row['tel']}</td>

					<td>{$row['address']}</td>

					<td>{php echo date('Y/m/d H:i',$row['createtime']);}</td>

					<td>{if $row['consumetime'] == 0}未使用{else}{php echo date('Y/m/d H:i',$row['consumetime']);}{/if}</td>

					<td>

						<a class="btn btn-default" href="#" onclick="drop_confirm('确认设置为未兑换?','{php echo $this->createWebUrl('setstatus',array('status'=>1,'id'=>$row['id'],'rid'=>$row['rid']))}');"><i class="fa fa-ban"></i> 未兑换</a>

						<a class="btn btn-default" href="#" onclick="drop_confirm('确认设置为已兑换?','{php echo $this->createWebUrl('setstatus',array('status'=>2,'id'=>$row['id'],'rid'=>$row['rid']))}');"><i class="fa fa-check-circle-o"></i> 已兑换</a>

					</td>

				</tr>


				{/loop}
				<tr>

					<td colspan="7">

						<input type="button" class="btn btn-primary" name="deletea" value="删除选择的" />

					</td>

				</tr>

			</tbody>

		</table>

	</div>

</div>

</div>

{$pager}

</div>
<script>
$(function(){
    $(".check_all").click(function(){
       var checked = $(this).get(0).checked;
		$(':checkbox').each(function(){this.checked = checked});
    });
	$("input[name=deletea]").click(function(){

		var check = $("input:checked");
		if(check.length<1){
			err('请选择要删除的记录!');
			return false;
		}
        if( confirm("确认要删除选择的记录?")){
		var id = new Array();
		check.each(function(i){
			id[i] = $(this).val();
		});
		$.post('{php echo $this->createWebUrl('deletea')}', {idArr:id},function(data){
			if (data.type ==0)
			{
				alert('删除成功！');
				location.reload();
			} else {
				alert(data.error);
			}


		},'json');
		}

	});
});
</script>
<script>

$(".phone").click(function() {

	$(".phone").addClass('label-teal');

	$(".phone").text('显示手机号');

	obj=$(this);

	obj.text('加载中...');

	fans=obj.attr('data-fans');

	$.post("{php echo $this->createWebUrl('getphone',array('rid'=>$rid))}", { fans: fans},

	function(data){

		obj.removeClass('label-teal');

		obj.text(data);

	});



});

	function drop_confirm(msg, url){

    if(confirm(msg)){

        window.location = url;

    }

}

</script>

{template 'common/footer'}